zoukankan      html  css  js  c++  java
  • [Javascript] Hositing

    First, memory is set aside for all necessary variables and declared functions.

    Function expression never got hosited in Javascirpt. Therefore, you can see var x = undefined;

    Examples: 

    Defined function will move top in front of return statment.

    Example 3: Function expressions are never hoisted! They are treated as assignments.

    Example 4: Picture below the noSeats and seatsAvail functions will never get chances to show off. Because when call noSeats() inside if statment, it is undefined!!. Javascirpt return error!

    So How to fix the problem?

    One: Move the function expressions to the top:

    Two: Using decared function instead.

  • 相关阅读:
    0325JavaScript
    0322css样式表,选择器
    0320表单
    0313函数
    0312数组
    0311类
    0309笔记整理
    进制转换
    Xcode快捷键大全
    Android LearningNotes
  • 原文地址:https://www.cnblogs.com/Answer1215/p/3892551.html
Copyright © 2011-2022 走看看