inherit.js

来自「这是《JavaScript学习源代码》一书的源代码」· JavaScript 代码 · 共 21 行

JS
21
字号
// create a car constructor function
function car( maker, model, color)
{
  this.maker = maker || "Dodge";
  this.model = model || "Viper";
  this.color = color || "Silver";
  this.startup = startup; 
}

// define the startup function
function startup()
{
  alert("... the motor is now running!");
}

// create an instance of the car object...
var vette = new car("Chevrolet", "Corvette", "Red");

// display the instance values
alert( vette.color+ " "+vette.maker + " " + vette.model);
vette.startup();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?