CodeWars for JavaScript

SubClass

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

Sub classing with extendsEdit

The extends keyword is used in class declarations or class expressions to create a class as a child of another class.

https://www.codewars.com/kata/basic-subclasses-adam-and-eve/train/javascript

class God{
/**
 * @returns Human[]
 */
  static create(){
    // code
    var array = new Array();
    array.push(new Man());
    array.push(new Woman());
    return array;
  }
}
// code
class Human{}
class Man extends Human{}
class Woman extends Human{}

类型比较

https://www.codewars.com/kata/for-twins-1-types/train/javascript

function typeValidation(variable, type) {
  // Your code should be here ;) 
  var tempType = typeof(variable);
  if(tempType === type)
  {
      return true;
  }else
  {
      return false;
  }
}
原文地址:https://www.cnblogs.com/chucklu/p/7593165.html