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

16 lines
622 B
JavaScript

// String method tests: startsWith, endsWith, replace, repeat, substring, lastIndexOf, concat
console.log("hello".startsWith("hel"));
console.log("hello".startsWith("xyz"));
console.log("hello".endsWith("llo"));
console.log("hello".endsWith("xyz"));
console.log("hello world".replace("world", "rust"));
console.log("ab".repeat(3));
console.log("hello".substring(1, 4));
console.log("abcabc".lastIndexOf("abc"));
console.log("hello".concat(" ", "world"));
console.log("hello".charCodeAt(0));
console.log("hello".trimStart());
console.log("hello".trimEnd());
console.log("hello".toString());
console.log("hello".valueOf());