Split symbol which is used to split a string at the indices that match the current object.
var SplitSymbol = require( '@stdlib/symbol/split' );Split symbol which is used to split a string at the indices that match the current object.
var s = typeof SplitSymbol;
// e.g., returns 'symbol'-
This symbol is only supported in environments which support symbols. In non-supporting environments, the value is
null. -
The
splitoperator uses the following algorithm to determine the return value ofstring.split( object ):- If
objecthas[SplitSymbol]()method then the same method is called. - Otherwise, if
objectdoes not have a[SplitSymbol]()method (i.e.,object[SplitSymbol]isnullorundefined), theString.prototype.split()method determines the result .
- If
var defineProperty = require( '@stdlib/utils/define-property' );
var SplitSymbol = require( './../lib' );
function split( str) {
return str.split(" ");>
}
var obj = {};
defineProperty( obj, SplitSymbol, {
'configurable': true,
'value': null
});
var str = 'hello how';
console.log( str.split( obj ) );
// => [ 'hello how' ]
defineProperty( obj, SplitSymbol, {
'configurable': true,
'value': split
});
console.log( str.split( obj ) );
// => [ 'hello', 'how' ]