{"id":22065137,"url":"https://github.com/wilddylan/dljavascript","last_synced_at":"2026-04-28T21:02:06.945Z","repository":{"id":30780180,"uuid":"34337011","full_name":"wilddylan/DLJavaScript","owner":"wilddylan","description":"Study JavaScriptCore And JavaScript","archived":false,"fork":false,"pushed_at":"2015-04-21T15:57:29.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T00:25:34.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wilddylan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-21T15:54:23.000Z","updated_at":"2015-04-21T15:54:23.000Z","dependencies_parsed_at":"2022-09-07T17:36:02.907Z","dependency_job_id":null,"html_url":"https://github.com/wilddylan/DLJavaScript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddylan%2FDLJavaScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddylan%2FDLJavaScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddylan%2FDLJavaScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddylan%2FDLJavaScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilddylan","download_url":"https://codeload.github.com/wilddylan/DLJavaScript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245144974,"owners_count":20568056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T19:15:11.612Z","updated_at":"2026-04-28T21:02:01.923Z","avatar_url":"https://github.com/wilddylan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# DLJavaScript\nStudy JavaScriptCore And JavaScript\n\n```objective-c\n// 创建新的Context\n    JSContext * context = [[JSContext alloc] init];\n    \n    // 执行JS 代码\n    [context evaluateScript:@\"var num = 5 + 5\"];\n    [context evaluateScript:@\"var names = ['Grace', 'Ada', 'Margaret']\"];\n    [context evaluateScript:@\"var triple = function(value) { return value * 3 }\"];\n    \n    // 直接执行JS代码 并且得到返回结果, 也可以先取到值、再去CallWithArgument或者拿出数组中的数据\n    JSValue * tripleNum = [context evaluateScript:@\"triple(num)\"];\n    \n    NSLog(@\"%d\", [tripleNum toInt32]);\n    \n    // 得到JS里边的一些值、\n    JSValue *names = context[@\"names\"];\n    // 从值中取出数据\n    JSValue *initialName = names[0];\n    \n    NSLog(@\"The first name: %@\", [initialName toString]);\n    \n    // 得到JS中的一个方法\n    JSValue *tripleFunction = context[@\"triple\"];\n    // 使用一个参数 传入到方法中\n    JSValue *result = [tripleFunction callWithArguments:@[@5] ];\n    \n    NSLog(@\"Five tripled: %d\", [result toInt32]);\n    \n    // 异常通过JSValue的方式抛出、\n    [context setExceptionHandler:^(JSContext * context, JSValue * exception) {\n       \n        NSLog(@\"JS Error: %@\", exception);\n    }];\n    \n    // 执行一句错误的JS代码、 以便我们抛出异常\n    [context evaluateScript:@\"function multiply(value1, value2) { return value1 * value2 \"];\n    \n    // Throw exception\n    NSArray * array = [NSArray arrayWithObjects:@\"1\", @\"2\", nil];\n    @try {\n        \n        NSInteger excep = [array[5] integerValue] + [array[10] integerValue];\n        NSLog(@\"%ld\", excep);\n    }\n    @catch (NSException *exception) {\n        @throw exception;\n    }\n    @finally {\n        \n    }\n```\n\n`Let's Fix Bug...`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilddylan%2Fdljavascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilddylan%2Fdljavascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilddylan%2Fdljavascript/lists"}