Skip to content

Instantly share code, notes, and snippets.

@BeRo1985
Created May 15, 2019 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeRo1985/3973f2b13fae2f66da7320ff6e012fc2 to your computer and use it in GitHub Desktop.
Save BeRo1985/3973f2b13fae2f66da7320ff6e012fc2 to your computer and use it in GitHub Desktop.
JS Bin ecmascript string type wierdness fun // source https://jsbin.com/xinogin
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="ecmascript string type wierdness fun">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
regExString = /string/gi;
typeName = "TEmailString";
otherTypeName = typeName + "";
console.log(regExString.test(typeName));
console.log(regExString.test(typeName + ""));
console.log(regExString.test(otherTypeName));
console.log("");
console.log(typeName.match(regExString) ? true : false);
console.log((typeName + "").match(regExString) ? true : false);
console.log(otherTypeName.match(regExString) ? true : false);
console.log("");
console.log(typeof typeName);
console.log(typeof (typeName + ""));
console.log(typeof otherTypeName);
console.log("");
</script>
<script id="jsbin-source-javascript" type="text/javascript">regExString = /string/gi;
typeName = "TEmailString";
otherTypeName = typeName + "";
console.log(regExString.test(typeName));
console.log(regExString.test(typeName + ""));
console.log(regExString.test(otherTypeName));
console.log("");
console.log(typeName.match(regExString) ? true : false);
console.log((typeName + "").match(regExString) ? true : false);
console.log(otherTypeName.match(regExString) ? true : false);
console.log("");
console.log(typeof typeName);
console.log(typeof (typeName + ""));
console.log(typeof otherTypeName);
console.log(""); </script></body>
</html>
regExString = /string/gi;
typeName = "TEmailString";
otherTypeName = typeName + "";
console.log(regExString.test(typeName));
console.log(regExString.test(typeName + ""));
console.log(regExString.test(otherTypeName));
console.log("");
console.log(typeName.match(regExString) ? true : false);
console.log((typeName + "").match(regExString) ? true : false);
console.log(otherTypeName.match(regExString) ? true : false);
console.log("");
console.log(typeof typeName);
console.log(typeof (typeName + ""));
console.log(typeof otherTypeName);
console.log("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment