VS Code调试js

来源:互联网 发布:国外问卷调查赚钱知乎 编辑:程序博客网 时间:2024/06/04 23:34

[TOC]

精通javaScript1-1为例:

//'Lecture'类的构造函数//用名称(name)和教师(teacher)作为参数function Lecture(name, teacher) {    //    this.name = name;    this.teacher = teacher;}Lecture.prototype.display = function () {    return this.teacher + " is teaching " + this.name;}function Schedule(lectures) {    this.lectures = lectures;}Schedule.prototype.display = function () {    var str = "";    for (var i = 0; i < this.lectures.length; i++) {        str += this.lectures[i].display() + " ";    }    return str;}var mySchedule = new Schedule([    new Lecture("Gym", "Mr. Smith"),    new Lecture("Gym", "Mr. Smith"),    new Lecture("Gym", "Mr. Smith")]);console.log(mySchedule.display())
  1. VS Code ->帮助->切换开发人员工具,打开调试开发人员工具视图


  2. 选择console,点击shift+enter可以进行多行编辑,此时把右边的代码,复制粘进去,可以看到运行结果(这里用的是console,当然也可一用alert)。