Learn JavaScript_1

chloe·2020년 8월 20일
0

Javascript

목록 보기
7/13

Console

the console keyworkd refers to an object, a collection of data and actions, that we can use in our code.
Keywords are words that are built into the JS language, so the computer will recognize them and treats them specially.
It's going to be easy for us to print values to the console, so we can see the work that we're doing.

Comments

As we write JavaScript, we can write comments in our code that the computer will ignore as our program runs. These comments exist for human readers.
There are two types of code comments in JavaScript.
1.ex) // prints 5 to the console
console.log(5);

/*This is all commented
console.log(10);*/

console.log(/*IGNORED!*/5);//still just prints 5

Data Types

Data types are the classifications we give to the different kinds of data that we use in programming.

  • Number:Any number, including wirh decimals(ex 4,8,23.42)
  • String:Any grouping of characters on your keyword(letters,numbers,spaces,symbols,etc.) surrounded by single quotes:'...' or double quotes"..."
  • Boolean: This data type only has two possible value (true,false)
  • Null :This data type represents the intentional absence of a value, and is represented by the keyworkd null
  • Undefined: This data type is denoted by the keyword undefined.
    It also represents the absence of a value though it has a different use than null
  • Symbol: A newer feature to the language, symbols are unique identifiers,useful in more complex coding.
  • Object: Collections of related data.

Arithmetic Operators

Basic arithmetic often comes in handy when programming.
An operator is a charater that performs a task in our code.

  • Add: +
  • Subtract: -
  • Multiply: *
  • Divide: /
  • Remainder: %
    The remainder operator sometimes called modulo.

String Concatenation

when a +operator is used on two strings, it appends the right string to the left string: This is called concatenation
console.log('hi'+'ya');//prints 'hiya'

Properties

When you introduce a new piece of data into a JavaScript program, the browser saves it as an instance of the data type. Every string instance has a property called length that stores the number of characters in that string.
console.log('Hello'.length);//5

Methods

Remember that methods are actions we can perform
ex)'example String'.methodName()
console.log('hello'.toUpperCase());//HELLO

Built-in Objects

In addition to console, there are other objects built into JavaScript.
For example, if you want to perform more complex mathematical operations tha arithmetic, JS has the built-in Math object.
ex) console.log(Math.random()); This method returns a random number between 0 and 1. To generate a random number between 0 and 50,we could multiply this result by 50-> Math.random()50;
Math.floor() takes a decimal number and round down to the nearest whole number.
console.log(Math.floor(math.random()
50));//prints a random whole number between 0 and 50

참고:codecademy

profile
Front-end Developer 👩🏻‍💻

4개의 댓글

comment-user-thumbnail
2021년 8월 11일

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. MEGA888

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

Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks ดูหนังออนไลน์

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

Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post. world's best back scratcher

답글 달기
comment-user-thumbnail
2021년 11월 15일

Level up your data analysis skills with the Power BI training Malaysia from TED Learning. Visit our website to enroll in the program and get certification.

답글 달기