“In C++ or C#, when we’re talking about objects, we’re referring to instances of classes or structs. Objects have different properties and methods, depending on which templates (that is, classes) they are instantiated from. That’s not the case with JavaScript objects. In JavaScript, objects are just collections of name/value pairs – think of a JavaScript object as a dictionary with string keys.”

摘录来自: Manuel Kiessling. “The Node Beginner Book”

自己在 node 中尝试

> var handle = {}
> handle["/"] = 'aaa';
> handle["/start"] = 'aaa/start';
> handle["/upload"] = 'aaa/upload';
> handle
{ '/': 'aaa',
'/start': 'aaa/start',
'/upload': 'aaa/upload' }
> typeof(handle)


电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.