Js My Notes
Js My Notes
Topic
* In JavaScript, values and variables are fundamental concepts that form the
basis of programming.
* Values: A value is a piece of information that a program can work with. It can
be a number, text, true/false, or more complex data.
* Variables: A variable is a container that holds a value. It has a name and can
be used to store and manipulate data in a program.
! Let's test
* Data types define the type of values that a variable can hold.
? Symbol: Represents a unique and immutable data type, often used to create
unique identifiers.
Example:
const mySymbol = Symbol("description");
! ==============================
! Data Types Interview Questions
! ==============================
In JavaScript, null and undefined are two distinct types that represent different values. By
definition, undefined means a variable has been declared but has not yet been assigned a
value, whereas null is an assignment value, meaning that a variable has been declared and
given the value of null .
Typeof in JavaScript is an operator used for type checking and returns the data type of the
operand passed to it. The operand can be any variable, function, or object whose type you want
to find out using the typeof operator.
examples.❓
Basically, if the variable value is false, zero, empty, null, undefined, or Nan , it's falsy and the
code within the if block is not run. If the variable value is anything else, such as a number that is
not zero, a non-empty string, an array, or an object, it's truthy and the code in the if block is run.
? parseInt and parseFloat are both functions in JavaScript used for converting
strings to numbers, but they have different use cases.
? parseInt is used for converting to integers and ignores anything after the
decimal point.
? Both functions will attempt to convert as much of the string as possible until
an invalid character is encountered.