Boostjs is a tiny library that adds common functionality to Javascript objects. Some of this features are present in other languages and many developers wonder why they were not added to Javascript.
None of this methods modifies the native objects in a way that it can affect functionality. In the worst case, junior developers may try to use these features without knowing they are not part of the language itself so please use with care.
Determines whether a string contains another string or not
var myStr = "Hello!";
assert.equal(myStr.contains("l"), true);
Replaces all ocurrences of a given string in another string
var myStr = "Hello World!";
assert.equal(myStr.replaceAll("o", "0"), "Hell0 W0rld!");
Removes an element from an array and returns the removed element.
var myArr = ["bannanas", "apples", "oranges"]
myArr.remove("apples");
assert.equal(myArray.indexOf("apples"), -1);
Determines whether an array contains an object or not
var myArr = ["bannanas", "apples", "oranges"]
assert.equal(myArray.contains("apples"), true);
Returns a clone of the object
var obj = { myProperty: "some string" };
obj.clone();
Short hand for JSON.stringify(object);
var obj = { myProperty: "some string" };
obj.toJson();
function Parent() {}
Parent.prototype.doSomething = function() {
return "I'm doing something now";
};
function Child() {}
Child.inherits(Parent);
var child = new Child();
child.doSomething();