TIL12 - JS - Intro

Peter D Lee·2020년 8월 26일
0

JavaScript

목록 보기
1/19
post-thumbnail

JavaScript Intro

1. Printing to Console

console.log();

In Javascript, it is a good practice to end all lines of code with ;

2. Comments

//

  • Comments out a single line
    > ex)
//Print 5 to console
console.log(5);
  • Can also be used to add comment at the end of a line of code
    > ex)
console.log(5); //Prints 5 to console

/* Comments */

  • Comments out multiple lines
    > ex)
/* This is
an example of
commenting out multiple lines */
  • Can also be used to add comment within a line of code
    > ex)
console.log(/* Print this value */ 5);

3. Data Types

In Javascript, there are 7 fundamental data types:

  • Number
  • String
  • Boolean
  • Null
  • Undefined
  • Symbol
  • Object

*The first 6 of the above are primitive data types
*The Object data type is more complex

4. Properties & Methods

Objects, including instances of data types, in Javascript have unique properties and methods that can be called on to implement various functions

properties & methods of an object are called with the . operator

Properties
Properties are unique features of an object

  • properties are called with the following syntax:
    obejct/instance name + . + property name
  • ex) 'hello'.length
    Here, .length is a property of the string instance 'hello'
    > calling 'hello'.length with console.log() will print the length of the string 'hello' to the console

Methods
Methods are unique actions you can perform on an object

  • methods are called with the following syntax:
    obejct/instance name + . + property name + ()
  • ex) console.log()
    Here, .log() is a method of Javascript's built-in obejct console
  • ex) 'hello'.toUpperCase()
    Here, .toUpperCase() is a method for the string object instance 'hello'

5. Built-in Objects

Javascript provides objects 'built-in' to the language, like Math obejct, which are a collection of properties and methods that can be accessed to perform tasks

5개의 댓글

comment-user-thumbnail
2021년 8월 8일

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. F95zone

답글 달기
comment-user-thumbnail
2021년 8월 16일

Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. 먹튀폴리스

답글 달기
comment-user-thumbnail
2021년 8월 17일

This article was written by a real thinking writer without a doubt. I agree many of the with the solid points made by the writer. I’ll be back day in and day for further new updates. 먹튀검증

답글 달기
comment-user-thumbnail
2021년 8월 21일

Thanks for another wonderful post. Where else could anybody get that type of info in such an ideal way of writing? A-esthetic.co.uk

답글 달기
comment-user-thumbnail
2021년 8월 22일

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! Nomad Yachting

답글 달기