DEV Community

shinyo627
shinyo627

Posted on

JS Intro

example below:

console.log(9999999999999999); // 10000000000000000
console.log(9999999999999999n); // 9999999999999999n
Enter fullscreen mode Exit fullscreen mode
  • Objects, including instances of data types, can have properties, stored information. The properties are denoted with a . after the name of the object, for example: 'Hello'.length.

  • Objects, including instances of data types, can have methods which perform actions. Methods are called by appending the object or instance with a period, the method name, and parentheses. For example: 'hello'.toUpperCase().

  • We can access properties and methods by using the ., dot operator.

  • Built-in objects, including Math, are collections of methods and properties that JavaScript provides.

  • Properties of an object can be either a value, or a method (a function only accessible to an instance of the object). A method is an attribute, but that does not make an attribute a method. A method is function, so performs some task. .length is a value, only.

  • String.prototype.trim() = method removes whitespace from both ends of a string and returns a new string, without modifying the original string


What does it mean by an instance of a data type?

a = 42
Enter fullscreen mode Exit fullscreen mode

Above we assign an integer value (a number) to the variable, a. When we poll the type of a we are actually polling the type of 42. a is not an object, but a reference to an object. 42 is identified by the interpreter as being a number type so gives it a wrapper object of that type.

typeof 42  =>  'number'

typeof a   =>  'number'
Enter fullscreen mode Exit fullscreen mode

So a refers to an instance of a number type.

Top comments (0)