Giter Site home page Giter Site logo

dailyjs's People

Contributors

xuyuan923 avatar

Watchers

 avatar

dailyjs's Issues

2015.1.23实现"String".reverse() // return "gnirtS"

/*
* 在String对象的原型上创建一个方法,实现以下功能
* "String".reverse() // return "gnirtS"
* "Super awesome string here" //return "ereh gnirts emosewa repuS"
*
* */

String.prototype.reverse = function(){

};

//测试代码
"asdf".reverse() === "fdsa"

2015.1.23 Array.prototype.reduce

现在你有一个复杂的多重嵌套的对象,但是你莫名蛋疼,突然就不想用if obj.property == null这个方法。于是乎打算,在Object的原型上创建一个方法(prototype method),传递一个路径,返回undefined 或 值(value)

Object.prototype.hash = function(path){

}

var obj = {
  person: {
    name: 'joe',
    history: {
      hometown: 'bratislava',
      bio: {
        funFact: 'I like fishing.'
      }
    }
  }
};

obj.hash('person.name'); // 'joe'
obj.hash('person.history.bio'); // { funFact: 'I like fishing.' }
obj.hash('person.history.homeStreet'); // undefined
obj.hash('person.animal.pet.needNoseAntEater'); // undefined

2015.1.24 arguments.callee()

/*
参数 number
返回 number
*/

function fib(num){

}

fib(1); // === 0
fib(2); // === 1
fib(3); // === 1
fib(4); // === 2
fib(5); // === 3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.