or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
JavaScript for beginner
Benson
a lot of meme like this
why?
Thanks for JS - meme
but today, we'll start from the very basic JS syntax
so don't worry about it :DD.
the most IMPORTANT skill
u need to before learning anything in JS
console.log
Declaring JavaScript Variables
var
let
const
NOTE:before 2015 only var, but global will cause some problem,after 2015, "const,let" born! "let" limited in scope, "var" in global
JS identifiers (names) rules
must begin with:
A letter (A-Z or a-z)
A dollar sign ($)
Or an underscore (_)
JS Operators
JS Arithmetic Operators
JS Comparison Operators
NOTE: Emphasize "===","?"
=== vs ==
NOTE:equal value equal type
ternary operator
syntax:
example:
JS data type
JS Types are Dynamic
common type
Strings
Numbers
Booleans
Arrays
Objects
specific type
Undefined
Null
NOTE:In JavaScript null is "nothing"
You can consider it a bug in JavaScript that typeof null is an object. It should be null.
The typeof Operator
Difference Between Undefined and Null
JS for Loops
syntax:
function expressions:
😱😨😰
JS if else and else if
syntax
JS function
syntax
JS setTimeout()
syntax
setTimeout example
Challenge Time
level 1
use "for" and "if" statement to print out following result.

level 2
use "for" and "setTimeout" statement

print every 2 second after passing
be smart! don't just paste the code 5 times!
level 3
JS Array
Syntax
Popping
Pushing
Shifting Elements
Deleting Elements
Map
Slice
JS Spread syntax
syntax
example
Challenge Time
try to use previous Array methods &
following array
to console like this.
END