Skip to content

Instantly share code, notes, and snippets.

@BeRo1985
Created May 15, 2019
Embed
What would you like to do?
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