(三)underscore.js架構Objects類API學習,underscore.js
keys_.keys(object)
Retrieve all the names of the object's properties.
_.keys({one: 1, two: 2, three: 3});=> ["one", "two", "three"]
values_.values(object)
Return all of the values of the object's properties.
_.values({one: 1, two: 2, three: 3});=> [1, 2, 3]
pairs_.pairs(object)
Convert an object into a list of [key, value] pairs.
_.pairs({one: 1, two: 2, three: 3});=> [["one", 1], ["two", 2], ["three", 3]]
invert_.invert(object)
Returns a copy of the object where the keys have become the values and the values the keys. For this to work, all of your object's values should be unique and string serializable.
_.invert({Moe: "Moses", Larry: "Louis", Curly: "Jerome"});=> {Moses: "Moe", Louis: "Larry", Jerome: "Curly"};
functions_.functions(object) Alias: methods
Returns a sorted list of the names of every method in an object — that is to say, the name of every function property of the object.
_.functions(_);=> ["all", "any", "bind", "bindAll", "clone", "compact", "compose" ...
extend_.extend(destination, *sources)
Copy all of the properties in the source objects over to the destination object, and return the destination object. It's in-order, so the last source will override properties of the same name in previous arguments.
_.extend({name: 'moe'}, {age: 50});=> {name: 'moe', age: 50}說明:extend函數是直接修改destination參數的,通過下面代碼很容易證明
var destination = {name: 'moe'};var source = {age: 50}_.extend(destination, source);console.log("extend="+destination.age);//50
pick_.pick(object, *keys)
Return a copy of the object, filtered to only have values for the whitelisted(白名單) keys (or array of valid keys). Alternatively accepts a predicate indicating which keys to pick.
_.pick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age');=> {name: 'moe', age: 50}_.pick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) { return _.isNumber(value);});=> {age: 50}
omit_.omit(object, *keys)
Return a copy of the object, filtered to omit the blacklisted(黑名單) keys (or array of keys). Alternatively accepts a predicate indicating which keys to omit.
_.omit({name: 'moe', age: 50, userid: 'moe1'}, 'userid');=> {name: 'moe', age: 50}_.omit({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) { return _.isNumber(value);});=> {name: 'moe', userid: 'moe1'}
defaults_.defaults(object, *defaults)
Fill in undefined properties in object with the first value present in the following list ofdefaults objects.
var iceCream = {flavor: "chocolate"};_.defaults(iceCream, {flavor: "vanilla", sprinkles: "lots"});=> {flavor: "chocolate", sprinkles: "lots"}說明:這個函數和extend很類似,如果destination和source中屬性名稱沒有重複,那麼2個函數的功能是完全一致的。
差別在於:當屬性名稱有同名的時候,extend直接用source中的值覆蓋掉destination中的值;而defaults則會根據destination中的屬性值是否為undefined區別對待。
var iceCream = {flavor: "chocolate",sprinkles:undefined};_.defaults(iceCream, {flavor: "vanilla", sprinkles: "lots"});console.log("iceCream=" + iceCream.flavor);//chocolateconsole.log("sprinkles=" + iceCream.sprinkles);//lots
clone_.clone(object)
Create a shallow-copied(淺拷貝) clone of the object. Any nested objects or arrays will be copied by reference, not duplicated.
_.clone({name: 'moe'});=> {name: 'moe'};
tap_.tap(object, interceptor)
Invokes interceptor with the object, and then returns object. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
_.chain([1,2,3,200]) .filter(function(num) { return num % 2 == 0; }) .tap(alert) .map(function(num) { return num * num }) .value();=> // [2, 200] (alerted)=> [4, 40000]
has_.has(object, key)
Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe reference to the hasOwnProperty function, in case it's been overridden accidentally.
_.has({a: 1, b: 2, c: 3}, "b");=> true
property_.property(key)
Returns a function that will itself return the key property of any passed-in object.
var moe = {name: 'moe'};'moe' === _.property('name')(moe);=> true
matches_.matches(attrs)
Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs.
var ready = _.matches({selected: true, visible: true});var readyToGoList = _.filter(list, ready);
isEqual_.isEqual(object, other)
Performs an optimized deep comparison between the two objects, to determine if they should be considered equal.
var moe = {name: 'moe', luckyNumbers: [13, 27, 34]};var clone = {name: 'moe', luckyNumbers: [13, 27, 34]};moe == clone;=> false_.isEqual(moe, clone);=> true
isEmpty_.isEmpty(object)
Returns true if an enumerable object contains no values (no enumerable own-properties). For strings and array-like objects _.isEmpty checks if the length property is 0.
_.isEmpty([1, 2, 3]);=> false_.isEmpty({});=> true
isElement_.isElement(object)
Returns true if object is a DOM element.
_.isElement(jQuery('body')[0]);=> true
isArray_.isArray(object)
Returns true if object is an Array.
(function(){ return _.isArray(arguments); })();=> false_.isArray([1,2,3]);=> true
isObject_.isObject(value)
Returns true if value is an Object. Note that JavaScript arrays and functions are objects, while (normal) strings and numbers are not.
_.isObject({});=> true_.isObject(1);=> false
isArguments_.isArguments(object)
Returns true if object is an Arguments object.
(function(){ return _.isArguments(arguments); })(1, 2, 3);=> true_.isArguments([1,2,3]);=> false
isFunction_.isFunction(object)
Returns true if object is a Function.
_.isFunction(alert);=> true
isString_.isString(object)
Returns true if object is a String.
_.isString("moe");=> true
isNumber_.isNumber(object)
Returns true if object is a Number (including NaN).
_.isNumber(8.4 * 5);=> true
isFinite_.isFinite(object)
Returns true if object is a finite Number.
_.isFinite(-101);=> true_.isFinite(-Infinity);=> false
isBoolean_.isBoolean(object)
Returns true if object is either true or false.
_.isBoolean(null);=> false
isDate_.isDate(object)
Returns true if object is a Date.
_.isDate(new Date());=> true
isRegExp_.isRegExp(object)
Returns true if object is a RegExp.
_.isRegExp(/moe/);=> true
isNaN_.isNaN(object)
Returns true if object is NaN.
Note: this is not the same as the native isNaN function, which will also return true for many other not-number values, such as undefined.
_.isNaN(NaN);=> trueisNaN(undefined);=> true_.isNaN(undefined);=> false
isNull_.isNull(object)
Returns true if the value of object is null.
_.isNull(null);=> true_.isNull(undefined);=> false
isUndefined_.isUndefined(value)
Returns true if value is undefined.
_.isUndefined(window.missingVariable);=> true
NET Framework包括哪3種技術
.NET Framework的核心技術為:通用語言運行庫(CLR:Common Language Runtime)、類庫、ASP.NET及ADO.NET
通用語言運行庫
(Common Language Runtime)
CLR引入了一些能提高應用程式運行可靠性的技術(比如消除了記憶體流失),同時也提供了多語言執行環境,使得組件和XML
Web服務的綜合使用不再受程式設計語言的限制。目前,可以用來編寫.NET應用程式的程式設計語言不下20種,如C++、 Visual Basic
.NET、JScript,以及微軟最新推出的開發語言——C#,此外還包括不少第三方的語言,比如COBOL、Eiffel、Perl、Python、
Smalltalk等等。
類庫
統一的類庫提供了調用平台函數的通用方法,使得我們不必再去學習並研究不同語言的API體繫結構
ASP.NET
ASP.NET建立在.NET
Framework類的基礎之上,並提供了由控制項和基礎部分組成的“Web程式模板”,大大簡化了Web程式和XML
Web服務的開發。程式員直接面對的是一組ASP.NET控制項,而這些控制項由一些諸如文字框、下拉選單等通用的HTML使用者介面構件封裝而成。實際上這些
控制項運行於Web伺服器上,並簡單地以HTML的形式將使用者介面發送到瀏覽器。
ADO.NET
與現有的ADO資料訪問模型相比,ADO.NET引入了一些新的特性——基於XML,並且是鬆散耦合的(loosely-coupled)。
ADO.NET使用了離線(disconnected)資料緩衝,使使用者能快速地建立出高效能、可靠的XML
Web服務和現在流行的多層應用程式(N-tier applications)。
希望幫到你
學習了Java SE的基礎知識(API沒學),現在要學習javaME,需不需要再學習javaSE中的API?
完全 可以...
p.s
互連的就是文法其他完全可以忽略.
能看懂se的代碼就能看懂me的代碼.因為文法完全一樣.只是在有的api函數上有所區別.其他沒有什麼直接聯絡.
像有些基礎類型操作是一樣的.比如io就差不多.只是沒有se中對象和方法那麼豐富.String對象也差不多.還有Date等等..區別就在於函數的不同.總之做me就找個api手冊看著.用到什麼方法慢慢查..在牛的人也不會上手三兩天的玩轉j2me.都是慢慢的沉澱和積累.