isReadOnly

Test if an ndarray is read-only.

Usage

var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' );

isReadOnly( arr )

Tests if an ndarray is read-only.

var array = require( '@stdlib/ndarray/array' );

var x = array( [ 1, 2, 3, 4 ], {
    'readonly': true
});
var bool = isReadOnly( x );
// returns true

Examples

var array = require( '@stdlib/ndarray/array' );
var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' );

var x = array( [ [ 1, 2 ], [ 3, 4 ] ], {
    'readonly': true
});
var bool = isReadOnly( x );
// returns true

x = array( [ [ 1, 2 ], [ 3, 4 ] ], {
    'readonly': false
});
bool = isReadOnly( x );
// returns false

x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
bool = isReadOnly( x );
// returns false
Did you find this page helpful?