Syntax and Functions

const

How const works in C++, the C keyword list and const in JavaScript.

Should I Use const or let?

Default to const for values you won't reassign and use let when a value must change. Here is how to choose, and why most modern code avoids var.

2 min read

What Are the 32 Keywords in C?

C has 32 reserved keywords in the original C89 standard, such as int, if and return. Here is the full list, grouped by purpose, plus later additions.

2 min read

What Is const vs. var in JavaScript?

const and var both declare variables in JavaScript, but they differ in scope, hoisting and reassignment. Here is how each works and when to pick one.

2 min read

What Is the Use of const?

In C++, const marks a value as read-only so the compiler catches accidental changes. Examples cover variables, function parameters and member functions.

2 min read

Related topics

More in syntax and functions

Primitive Data Types The built in C++ types, type casting and how other languages group data types. long long What the long long type holds and when you need a long integer. Signed vs Unsigned How signed and unsigned integers differ and how they look in binary. double and float What double stores, how big a float is and how to print floating point values. Integer Limits The minimum and maximum int values in C++ and how they compare with 1e9. sizeof How the sizeof operator measures types in bytes and how big an int really is. typeof and decltype How decltype and typeof deduce types, with a look at typeof in JavaScript. Enums How enums work in C++ and C, with examples of why you would use one. Declaration and Initialization Designated initializers and the difference between declaring and initializing variables and arrays. Conditional Operator How the ternary conditional operator works and how conditional statements are written. Comparison Operators The operators that compare values in C++ and how logical OR fits in. Assignment Operators Plain and compound assignment, plus the address and dereference operators. Increment Operator How prefix and postfix increment differ and when ++i is the better choice. Unary Operators The operators that act on a single operand and how they differ from ternary ones. Shift Operators How left and right shifts move bits, with small examples like 1 << n. Bitwise Operators XOR, NOT and the other bitwise operators, and how & differs from &&. Power Operator Whether C++ has an exponent operator and how to raise numbers to a power. Logical and Arithmetic Operators The OR operator and an overview of arithmetic and other C operators. Dot and Scope Operators How the dot operator reaches members and what the :: operator means. While Loops While loop syntax with examples and the three main kinds of loops. Do While Loops Example do while programs and how they compare with for and while loops. Break Statement How break exits loops and switch statements early. Switch Case How switch case statements work and when they beat a chain of ifs. If Else Statements If else syntax and how to build an else if ladder. goto What the goto jump statement does and how to use it in C and C++. Recursion How recursive functions work, why they need a base case and how they look in Python. Function Overloading Function overloading in C++, how it differs from overriding and from operator overloading. Function Prototypes What a function prototype is and how it relates to a function definition. Static Functions What static does to functions and variables and when to use it. inline What the inline keyword does and how inline functions differ from macros. using namespace std What namespaces are, what std means and when to write std:: yourself. using The roles of the using keyword in C++, plus the ternary operator. cout How to print output with std::cout and the << operator. Lambda Functions How C++ lambdas are written, what type they have and why they are useful. std::function How std::function stores callable objects, plus count() and the types of functions in C. Functions as Arguments How to pass a function to another function using pointers and other callables. Function Pointer Arrays How to build arrays of function pointers, starting from what an array is. Header Guards How header guards stop a file from being included twice. Header Files What .h files are for, with a worked C++ header file example. The Preprocessor What the preprocessor does to your code before it is compiled. Macros How macros work, how to stringify one and why C++ often avoids them.