2 JS of 20/80 key knowledge

Source: Internet
Author: User

1.

2

var a = 1;undefineda1alert (a); undefined

  

var b = True;var c = "Hi"; Undefinedalert (b); alert (c); undefined

  

function foo (bar) {alert (bar); return bar;} Undefinedvar z = foo ("Hi"); Undefinedz "HI"

  

function foo (bar) {alert (bar); return bar;}

  

    • Shift+enter line break

function foo (bar) {if (Bar > 3) {alert (bar + 1);} else {alert ("Not Enough");}} Undefinedfoo (5) Undefinedfoo (2); undefined

  

3

var arr = []undefinedfunction foo (bar) {if (Bar > 3) {arr.push (bar);} else {alert ("Not Enough");}} Undefinedfoo (2); Undefinedfoo (6); Undefinedarr; [6]

  

var o = {One:1,two:2}undefinedo.one1o.two2

  

4

Document#documentdocument.queryselector ("#sidebar") <div id=? " Sidebar ">?...? </div>?var el = document.queryselector ("#sidebar"); Undefinedel<div id=? " Sidebar ">?...? </div>?el.setattribute ("Style", "display:none;") Undefined

  

5

6

2 JS of 20/80 key knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.