Keywords comparison — JavaScript vs CPlusPlus
Take a fun interactive comparing,
If you couldn’t run here, please try with this link.
Keywords!
Keywords are reserved words. These are predefined by compilers. So, we can’t use the keywords as a variable name or object name or function name. Because Compiler already has the meaning for the keywords.
JS — JavaScript, CPP — CPlusPlus
Split the keywords of the JS and CPP with versions.
For JS,
Before and After ECMAScript 5/6.
For CPP,
Before and After CPP11.
JS!
Since ES6 there are 68 keywords living in JS.
keywords in JS,
jskeywords = [arguments, await, break, case, catch, class, const, continue, debugger, default, delete, do, else, enum, eval, export, extends, false, finally, for, function, if, implements, import, in, instanceof, interface, let, new, null , package, private, protected, public, return, static, super, switch, this, throw, true, try, typeof, var, void, while, with, yield, Array, Date, eval, function, hasOwnProperty, Infinity, isFinite, isNaN, isPrototypeOf, length, Math, NaN,name, Number, Object, prototype, String, toString, undefined, valueOf];
Exactly 16 keywords were removed in ES5. Only in ES5, Some keywords get removed. No other version has faced the removal of the keyword.
Removed keywords in ES5,
var removeKeywordsES5 = [abstract, boolean, byte, char, double, final, float, goto, int, long, native, short, synchronized, throws, transient, volatile];
CPP!
Since CPP11 version, there are 105 keywords living in CPP.
In CPP11, 10 keywords were added to CPP.
Keywords in CPP,
var cppKeywords = [alignas, alignof, and, and_eq, asm, atomic_cancel, atomic_commit, atomic_noexcept, auto, bitand, bitor, bool, break, case, catch, char, char8_t, char16_t, char32_t, class, compl, concept, const, consteval, constexpr, const_cast, continue, co_await, co_return, co_yield, decltype, default, delete, do, double, dynamic_cast, else, enum, explicit, export, extern, false, float, for, friend, goto, if, import, inline, int, long, module, mutable, namespace, new, noexcept, not, not_eq, nullptr, operator, or, or_eq, private, protected, public, reflexpr, register, reinterpret_cast, requires, return, short, signed, sizeof, static, static_assert, static_cast, struct, switch, synchronized, template, this, thread_local, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t, while, xor, xor_eq,override, final, audit, axiom, transaction_safe, transaction_safe_dynamic];
Let me compare keywords — JS vs CPP
When comparing CPP and JS, There are 29 keywords are common and 144 keywords are uncommon.
Common keywords fetched from JS and CPP are,
var sameKeywords = [else, return, enum, export, false, for, static, switch, break, if, case, import, this, catch, true, class, new, continue, private, while, default, delete, public, do, throw, protected, void, try, const];
Useful links!
- https://en.cppreference.com/w/cpp/keyword
- https://www.w3schools.com/js/js_reserved.asp
- https://mathiasbynens.be/notes/reserved-keywords
Suggestions are always welcome!
Thanks for your valuable time.
Day 25. That’s 1 blog, see you tomorrow!