Files
rust_browser/tests/external/js262/fixtures/function-name-call.js
Zachary D. Rowitsch 3528177867
All checks were successful
ci / fast (linux) (push) Successful in 6m35s
Add JS String methods, Function.name/.call(), Object.prototype.toString
Implement primitive string property access (.length) and 18 String
prototype methods (charAt, indexOf, slice, toUpperCase, trim, etc.),
Function.name/.length properties and Function.prototype.call() for
direct member-call syntax, and Object.prototype.toString.call() for
type-tag formatting via a new setup_builtins() initializer.

Changes NativeFn signature to receive Option<&JsValue> this parameter
so native functions can access their receiver. Adds repeat() safety
guard against Infinity/negative/OOM, fixes indexOf empty-string clamping
and lastIndexOf optional from parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 15:49:07 -05:00

18 lines
357 B
JavaScript

// Function.name, Function.length, and Function.prototype.call()
function greet(name) {
console.log("Hello " + name);
}
console.log(greet.name);
console.log(greet.length);
function add(a, b) {
return a + b;
}
console.log(add.call(null, 3, 4));
function getThis() {
return this.value;
}
var obj = { value: 42 };
console.log(getThis.call(obj));