{"id":20285433,"url":"https://github.com/mramshaw/strict","last_synced_at":"2026-05-17T08:34:18.439Z","repository":{"id":92906514,"uuid":"239200061","full_name":"mramshaw/Strict","owner":"mramshaw","description":"Experimenting with the new features introduced with ECMAScript version 5","archived":false,"fork":false,"pushed_at":"2020-02-08T20:50:35.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T03:44:33.348Z","etag":null,"topics":["ecmascript5","javascript","node","node-js","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mramshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-08T20:29:36.000Z","updated_at":"2020-02-08T20:50:37.000Z","dependencies_parsed_at":"2023-04-25T17:01:46.544Z","dependency_job_id":null,"html_url":"https://github.com/mramshaw/Strict","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mramshaw/Strict","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FStrict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FStrict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FStrict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FStrict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mramshaw","download_url":"https://codeload.github.com/mramshaw/Strict/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FStrict/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264324669,"owners_count":23590932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecmascript5","javascript","node","node-js","nodejs"],"created_at":"2024-11-14T14:26:40.372Z","updated_at":"2026-05-17T08:34:13.400Z","avatar_url":"https://github.com/mramshaw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strict\n\nA quick review of the new features introduced with ECMAScript version 5.\n\nSpecifically with reference to __null__ as well as __undeclared__ and __undefined__ data types.\n\nThese new features are invoked by specifying `'use strict'` with [node.js](http://nodejs.org/).\n\n## Rationale\n\nI often like to experiment with language features, for instance here are my experiments with\n[Golang](http://github.com/mramshaw/Golang).\n\nIn ___this___ repo I am trying out some things with `node.js`.\n\n## Method\n\nWe will compare and contrast two mainly identical pieces of code, one ___with___ 'use strict'\nand the other ___without___:\n\n```bash\n$ diff -uw strict.js not_strict.js \n--- strict.js\t2020-02-08 15:43:28.560093898 -0500\n+++ not_strict.js\t2020-02-08 15:35:35.486426106 -0500\n@@ -1,5 +1,3 @@\n-\"use strict\";\n-\n // --- null ---\n \n let a = null;\n@@ -34,7 +32,7 @@\n // $ node -c strict.js\n // SyntaxError: Delete of an unqualified identifier in strict mode.\n \n-//delete g;\n+delete g;\n \n // 'undefined'\n console.log(\"'g' is of type: \" + (typeof g));\n$\n```\n\nNote that the line 'delete g;' is commented-out in `strict.js`.\n\n#### node --check\n\n[This can also be abbreviated as `node -c`.]\n\nThis can be useful for catching errors, but it is really just a __syntax check__.\n\nFor instance:\n\n```bash\n$ node -c strict.js\n/home/owner/Documents/node.js/Strict/strict.js:37\ndelete g;\n       ^\n\nSyntaxError: Delete of an unqualified identifier in strict mode.\n    at new Script (vm.js:84:7)\n    at checkSyntax (internal/main/check_syntax.js:78:3)\n    at internal/main/check_syntax.js:42:3\n$\n```\n\nIt will not catch __runtime errors__.\n\n#### without 'use strict'\n\nHere we will explore __null__, __undeclared__ and __undefined__ data types.\n\n```bash\n$ node not_strict.js\nnull\n'a' is of type: object\n'null' is of type: object\na is null, 'a' === null ? = true\nundefined\n'b' is of type: undefined\nb is undefined, 'b' === undefined ? = true\nI am a Global variable\n'g' is of type: string\n'g' is of type: undefined\n$\n```\n\n[Data values can be compared to 'null' and 'undefined'.]\n\n#### with 'use strict'\n\nAnd here we will execute the same code (but with 'delete g;' commented-out),\nthis time with `\"use strict\"`:\n\n```bash\n$ node strict.js\nnull\n'a' is of type: object\n'null' is of type: object\na is null, 'a' === null ? = true\nundefined\n'b' is of type: undefined\nb is undefined, 'b' === undefined ? = true\n/home/owner/Documents/node.js/Strict/strict.js:25\ng = \"I am a Global variable\";\n  ^\n\nReferenceError: g is not defined\n    at Object.\u003canonymous\u003e (/home/owner/Documents/node.js/Strict/strict.js:25:3)\n    at Module._compile (internal/modules/cjs/loader.js:955:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)\n    at Module.load (internal/modules/cjs/loader.js:811:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:723:14)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)\n    at internal/main/run_main_module.js:17:11\n$\n```\n\n[As expected, \"use strict\" resulted in stricter syntax checking.]\n\n## Conclusion\n\nIn general, 'use strict' is very useful and can prevent lots of errors.\n\nHowever, adding it to older code may not always be a good idea. It can\ndefinitely break some older code.\n\nFor instance, the `this` keyword can behave differently in strict mode.\n\n## Reference\n\nSome useful references follow.\n\n#### null\n\nRead more about 'null': http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null\n\n\u003e The value `null` represents the intentional absence of any object value.\n\u003e It is one of JavaScript's [primitive values](http://developer.mozilla.org/en-US/docs/Glossary/Primitive)\n\u003e and is treated as [falsy](http://developer.mozilla.org/en-US/docs/Glossary/Falsy) for boolean operations.\n\n#### strict mode\n\nRead more about 'use strict': http://www.w3schools.com/js/js_strict.asp\n\n\u003e The `\"use strict\"` directive was new in ECMAScript version 5.\n\nECMAScript version 5 introduced new features. To allow for backward compatibility, these new features will\nonly apply if `\"use strict\"` is specified.\n\nAnd also: http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode\n\n#### undefined\n\nRead more about 'undefined': http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined\n\n\u003e The global `undefined` property represents the primitive value [undefined](http://developer.mozilla.org/en-US/docs/Glossary/Undefined).\n\u003e It is one of JavaScript's [primitive types](http://developer.mozilla.org/en-US/docs/Glossary/Primitive).\n\n## Versions\n\nThe version of `node.js` used was __v12.15.0__:\n\n```\n$ node -v\nv12.15.0\n$\n```\n\n## To Do\n\n- [ ] Verify with different versions of `node`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmramshaw%2Fstrict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmramshaw%2Fstrict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmramshaw%2Fstrict/lists"}