Skip to main content

About Type In Programming

Computers are sophisticated and can make use of more complex variables than just numbers. This is where variable types come in. Variables come in several types and different languages support different types.
The most common types are:

  1. Float: a number, like 1.21323, 4, -33.5, 100004 or 0.123
    Integer: a number like 1, 12, -33, 140 but not 1.233
    Numbers
  2. String: a line of text like "boat", "elephant" or "damn, you are tall!"
  3. Boolean: either true or false, but nothing else
  4. Arrays: a collection of values like: 1,2,3,4,'I am bored now'
  5. Objects: a representation of a more complex object
  6. null: a variable that contains null contains no valid Number, String, Boolean, Array, or Object
  7. undefined: the undefined value is obtained when you use an object property that does not exist, or a variable that has been declared, but has no value assigned to it.
JavaScript is a “loosely typed” language, which means that you don't have to explicitly declare what type of data the variables are. You just need to use the var keyword to indicate that you are declaring a variable, and the interpreter will work out what data type you are using from the context, and use of quotes.

Source By Gitbook

Comments

Popular posts from this blog

About Comment In Programming

Comments are statements that will not be executed by the interpreter, comments are used to mark annotations for other programmers or small descriptions of what your code does, thus making it easier for others to understand what your code does. In Javascript, comments can be written in 2 different ways: 1. Line starting with //: // This is a comment, it will be ignored by the interpreter var a = "this is a variable defined in a statement" ; 2. Section of code starting with /*and ending with */, this method is used for multi-line comments: /* This is a multi-line comment, it will be ignored by the interpreter */ var a = "this is a variable defined in a statement" ; source : gitbook "learn javascript"

About Equality in Programming

Programmers frequently need to determine the equality of variables in relation to other variables. This is done using an equality operator.+ The most basic equality operator is the == operator. This operator does everything it can to determine if two variables are equal, even if they are not of the same type. For example, assume: var foo = 42 ; var bar = 42 ; var baz = "42" ; var qux = "life" ; foo == bar will evaluate to true and baz == qux will evaluate to false, as one would expect. However, foo == baz will also evaluate to true despite foo and baz being different types. Behind the scenes the == equality operator attempts to force its operands to the same type before determining their equality. This is in contrast to the === equality operator. The === equality operator determines that two variables are equal if they are of the same type and have the same value. With the same assumptions as before, this means that foo === bar will still evaluate to t...