本文介紹了Jasmine.js 比較數(shù)組的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時(shí)送ChatGPT賬號(hào)..
jasmine.js中有沒有辦法檢查兩個(gè)數(shù)組是否相等,例如:
Is there a way in jasmine.js to check if two arrays are equal, for example:
arr = [1, 2, 3]
expect(arr).toBe([1, 2, 3])
expect(arr).toEqual([1, 2, 3])
似乎都不起作用.
推薦答案
剛剛做了測(cè)試,它可以與 toEqual
Just did the test and it works with toEqual
請(qǐng)找到我的測(cè)試:
http://jsfiddle.net/7q9N7/3/
describe('toEqual', function() {
it('passes if arrays are equal', function() {
var arr = [1, 2, 3];
expect(arr).toEqual([1, 2, 3]);
});
});
僅供參考:
toBe() 與 toEqual():toEqual() 檢查等價(jià)性.toBe(),在另一方面,確保它們是完全相同的對(duì)象.
toBe() versus toEqual(): toEqual() checks equivalence. toBe(), on the other hand, makes sure that they're the exact same object.
這篇關(guān)于Jasmine.js 比較數(shù)組的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!