Files
rust_browser/tests/external/js262/fixtures/string-methods-basic.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

14 lines
521 B
JavaScript

// String method tests: charAt, indexOf, includes, slice, toUpperCase, toLowerCase, trim
console.log("hello".charAt(0));
console.log("hello".charAt(4));
console.log("hello".charAt(99));
console.log("hello".indexOf("llo"));
console.log("hello".indexOf("xyz"));
console.log("hello world".includes("world"));
console.log("hello world".includes("xyz"));
console.log("hello".slice(1, 4));
console.log("hello".slice(-3));
console.log("HELLO".toLowerCase());
console.log("hello".toUpperCase());
console.log(" hello ".trim());