Skip to main content

Command Palette

Search for a command to run...

Basic Javascript #1_variable

Published
1 min readView as Markdown

right click on a webpage and select Inspect. We can use 'Console' tab for Javascript.

  • Let's make a list

let a_list = ['수박','참외','배']

  • a_list[1] shows '참외'

  • To add another variable, a_list.push('감')

  • a_list shows [수박', '참외', '배', '감']

Dictionary form

  • let a_dict = {'name':'bob','age':27}

  • a_dict['name'] shows 'bob'

  • add another variable a_dict['height'] = 180

a_dict shows {name: 'bob', age: 27, height: 180}

Separation

  • let myemail = 'sparta@gmail.com'

  • myemail.split('@') means separate myemail based on '@'

['sparta', 'gmail.com']

It's also a list.

  • myemail.split('@')[1] shows gmail.com

  • if you split this one more by '.'

myemail.split('@')[1].split('.')

['gmail', 'com']

  • myemail.split('@')[1].split('.')[0] shows gmail

More from this blog

Ollie Seongyong Kim

85 posts